﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefProduceDataType" :model="stateProduceDataType.vmModel" label-width="100px">
    <el-row>
      
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_lineCode_FormItem" prop="Entity.lineCode" label="产线号">
            <el-input v-model="stateProduceDataType.vmModel.Entity.lineCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_stationCode_FormItem" prop="Entity.stationCode" label="工位号">
            <el-input v-model="stateProduceDataType.vmModel.Entity.stationCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_dataType_FormItem" prop="Entity.dataType" label="数据类型">
            <el-input v-model="stateProduceDataType.vmModel.Entity.dataType" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_nameTable_FormItem" prop="Entity.nameTable" label="数据名表">
            <el-input v-model="stateProduceDataType.vmModel.Entity.nameTable" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_orderCode_FormItem" prop="Entity.orderCode" label="工单号">
            <el-input v-model="stateProduceDataType.vmModel.Entity.orderCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_scheduleCode_FormItem" prop="Entity.scheduleCode" label="排程号">
            <el-input v-model="stateProduceDataType.vmModel.Entity.scheduleCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_machineCode_FormItem" prop="Entity.machineCode" label="设备编码">
            <el-input v-model="stateProduceDataType.vmModel.Entity.machineCode" clearable></el-input>
        </el-form-item>
    </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitProduceDataType"  type="primary" :button-text="$t('message._system.common.vm.submit')" style="margin-top:15px;"/>
      <WtmButton @click="onCloseProduceDataType"  type="primary" :button-text="$t('message._system.common.vm.cancel')" style="margin-top:15px;"/>
    </div>
  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message._system.common.vm.edit;false">
import {  ElMessageBox, ElMessage } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { ProduceDataTypeApi } from '/@/api/baseinformation/ProduceDataType';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

// 定义变量内容
const formRefProduceDataType = ref();
const stateProduceDataType = reactive({
     vmModel: {
	  Entity:{
      			ID: null,
			lineCode: null,
			stationCode: null,
			dataType: null,
			nameTable: null,
			orderCode: null,
			scheduleCode: null,
			machineCode: null,

      },
      
	},
    
     
});

// 取消
const onCloseProduceDataType = () => {
    closeDialog();
};

// 提交
const onSubmitProduceDataType = () => {
    formRefProduceDataType.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            ProduceDataTypeApi().edit(stateProduceDataType.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            })
		}
	})
};

// 页面加载时
onMounted(() => {
    
     if (ci.attrs["wtmdata"]) {
		stateProduceDataType.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProduceDataType.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	ProduceDataTypeApi().get(stateProduceDataType.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateProduceDataType.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

